/**
 * @file   LoggerIoFilterAdapter.java
 * @date   2012-11-7上午9:48:24
 * @author User
 */
package com.gzceb.zhgjj.mina;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.core.write.WriteRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <p>日志过滤器类。</p>
 *
 * @date   2012-11-7上午9:48:24 
 * @author User
 * @description  用来记录日志
 */
public class LoggerIoFilterAdapter extends BaseIoFilterAdapter {

	 private final Logger log = LoggerFactory.getLogger(LoggerIoFilterAdapter.class);
	 //记录请求日志
	 @Override
	 public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception
	 {
	     //System.out.println("1111111111111111111== :"+message);
	     super.messageReceived(nextFilter, session, message);
	     log.info("Start recerving messages to : " + session.getLocalAddress());
	 }
     //记录返回日志
	 @Override
	 public void messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
	 {
	    super.messageSent(nextFilter, session, writeRequest);
	    log.info("End sending messages to: " + session.getRemoteAddress());
	 }

}
